package com.zl.autocode.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zl.autocode.controller.base.AutocodeBaseController;
import com.zl.autocode.dto.autocode.dict.ReqDictAddDTO;
import com.zl.autocode.dto.autocode.dict.ReqDictDelDTO;
import com.zl.autocode.dto.autocode.dict.ReqDictDetailDTO;
import com.zl.autocode.dto.autocode.dict.ReqDictEditDTO;
import com.zl.autocode.dto.autocode.dict.ReqDictQueryDTO;
import com.zl.autocode.dto.autocode.dict.ReqDictStateDTO;
import com.zl.autocode.dto.autocode.dict.ResDictAddDTO;
import com.zl.autocode.dto.autocode.dict.ResDictDelDTO;
import com.zl.autocode.dto.autocode.dict.ResDictDetailDTO;
import com.zl.autocode.dto.autocode.dict.ResDictEditDTO;
import com.zl.autocode.dto.autocode.dict.ResDictQueryDTO;
import com.zl.autocode.dto.autocode.dict.ResDictStateDTO;
import com.zl.autocode.service.autocode.IDictService;
import com.zl.common.dto.ReqDTO;
import com.zl.common.dto.ResDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 字典
 * @author ZL
 */
@Api(value="字典",tags ="字典")
@RestController("autocodeDictController")
@RequestMapping("/autocode/dict")
public class DictController extends AutocodeBaseController {

    @Autowired
    private IDictService dictService;
    
    /**
     * 查询
     */
    @ApiOperation(value="字典-查询")
    @RequestMapping(value="/list", method = RequestMethod.POST)
    public ResDTO<ResDictQueryDTO> listDict(@RequestBody ReqDTO<ReqDictQueryDTO> reqInfo) throws Exception{
        ResDictQueryDTO data = dictService.queryDictList(reqInfo);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="字典-详情")
    @RequestMapping(value="/detail", method = RequestMethod.POST)
    public ResDTO<ResDictDetailDTO> detailDict(@RequestBody ReqDTO<ReqDictDetailDTO> reqInfo) throws Exception{
        ResDictDetailDTO data = dictService.queryDictDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="字典-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
        public ResDTO<ResDictAddDTO> addDict(@RequestBody ReqDTO<ReqDictAddDTO> reqInfo) throws Exception{
        ResDictAddDTO data = dictService.insertDictInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="字典-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
        public ResDTO<ResDictEditDTO> editDict(@RequestBody ReqDTO<ReqDictEditDTO> reqInfo) throws Exception{
        ResDictEditDTO data = dictService.updateDictInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="字典-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
        public ResDTO<ResDictDelDTO> delDict(@RequestBody ReqDTO<ReqDictDelDTO> reqInfo) throws Exception{
        ResDictDelDTO data = dictService.deleteDictInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="字典-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
        public ResDTO<ResDictStateDTO> stateDict(@RequestBody ReqDTO<ReqDictStateDTO> reqInfo) throws Exception{
        ResDictStateDTO data = dictService.updateDictState(reqInfo);
        return successDATA(data); 
    }
    
    
}